﻿using QD.LopPlat.Models;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QD.LopPlat.Repository
{
    public class PlatMasterDbContext : DbContext
    {
        private static PlatMasterDbContext platMasterDbContextInstance;
        public static PlatMasterDbContext PlatMasterDbContextInstance
        {
            get
            {
                if (platMasterDbContextInstance == null)
                    platMasterDbContextInstance = new PlatMasterDbContext();

                return platMasterDbContextInstance;
            }
            set
            {
                platMasterDbContextInstance = value;
            }
        }

        private PlatMasterDbContext()
            : base(DataBaseRepository.SqlConnectionStr(true))
        {
            Database.SetInitializer<PlatDbContext>(null);
        }

        public DbSet<Sys_Tree> Sys_Tree { get; set; }
        public DbSet<Sys_TreeAnalysis> Sys_TreeAnalysis { get; set; }
        public DbSet<SysViews> SysViews { get; set; }
        public DbSet<Sys_CustomColumn> Sys_CustomColumn { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();//移除复数表名的契约

            base.OnModelCreating(modelBuilder);
        }
    }
}
